-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add JSDoc for common Type methods #1157
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some general thoughts + updated descriptions.
ark/type/methods/base.ts
Outdated
or<const def, r = type.infer<def, $>>( | ||
def: type.validate<def, $> | ||
): instantiateType<t | r, $> | ||
|
||
/** | ||
* Narrow this type to its subtype. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a custom predicate to the Type
.
ark/type/methods/base.ts
Outdated
array(): ArrayType<t[], $> | ||
|
||
/** | ||
* Morph this type with a chain of morphs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't show the different syntax kinds. Just summarize how the chaining works, and explain that types can be morphed through other types which will apply validation and morphs from those types.
ark/type/type.ts
Outdated
unit: UnitTypeParser<$> | ||
/** | ||
* Constructs a union of literals and by-reference objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a Type that is satisfied only by a value ===
to one of the arguments passed to this function.
ark/type/type.ts
Outdated
@@ -96,7 +101,18 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> { | |||
define: DefinitionParser<$> | |||
generic: GenericParser<$> | |||
schema: SchemaParser<$> | |||
/** | |||
* Construct a literal (or by-reference object) type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a Type that is satisfied only by a value ===
to the argument passed to this function.
ark/type/methods/base.ts
Outdated
@@ -42,12 +42,25 @@ import type { instantiateType } from "./instantiate.ts" | |||
interface Type<out t = unknown, $ = {}> | |||
extends Callable<(data: unknown) => distill.Out<t> | ArkErrors> { | |||
[inferred]: t | |||
/** | |||
* Generic argument. May be used for type reconstruction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The top-level generic parameter accepted by the Type
. Potentially includes morphs and subtype constraints not reflected in the types fully-inferred input (via inferIn
) or output (via infer
or inferOut
).
2909079
to
39c1f22
Compare
I'll tweak some of the examples a bit and publish in the next release 👍 |
No description provided.